package bb.lanxing.model.json;

import android.os.Parcel;
import android.os.Parcelable;
import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
import com.umeng.socialize.net.dplus.CommonNetImpl;
import gov.nist.core.Separators;
import bb.lanxing.lib.devices.sprint.entity.SettingSupports;
import bb.lanxing.util.JsonUtil;
import bb.lanxing.util.MedalUtil;
import java.io.Serializable;
import java.util.List;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

public class WorkoutLike implements Serializable, Parcelable {
    public static final Parcelable.Creator<WorkoutLike> CREATOR = new Parcelable.Creator<WorkoutLike>() {
        @Override
        public WorkoutLike createFromParcel(Parcel parcel) {
            return new WorkoutLike(parcel);
        }

        @Override
        public WorkoutLike[] newArray(int i) {
            return new WorkoutLike[i];
        }
    };
    private int age;
    @SerializedName("city_name")
    private String cityName;
    @SerializedName("ulevel")
    private int level;
    @SerializedName("main_team")
    private String mainTeam;
    @Expose(deserialize = false, serialize = false)
    private String medalSmall;
    @SerializedName("pic_url")
    private String picUrl;
    @SerializedName("license_number")
    private String plateNum;
    @SerializedName("pro_name")
    private String proName;
    private int sex;
    @SerializedName("total_distance")
    private long totalDistance;
    @SerializedName("medal_small")
    private List<UserAvatarMedal> userAvatarMedals;
    @SerializedName("user_id")
    private long userId;
    @SerializedName("user_name")
    private String userName;

    @Override
    public int describeContents() {
        return 0;
    }

    public WorkoutLike() {
    }

    public WorkoutLike(JSONObject jSONObject) throws JSONException {
        int lastIndexOf;
        JSONArray arrayValue;
        setUserId(jSONObject.getLong("user_id"));
        setUserName(jSONObject.getString("user_name"));
        setPicUrl(jSONObject.getString("pic_url"));
        setAge(jSONObject.getInt(SettingSupports.SUPPORT_ITEM_AGE));
        setSex(jSONObject.getInt(CommonNetImpl.SEX));
        setTotalDistance(jSONObject.getLong("total_distance"));
        setLevel(JsonUtil.getIntegerValue("ulevel", jSONObject));
        if (jSONObject.has("medal_small") && (arrayValue = JsonUtil.getArrayValue("medal_small", jSONObject)) != null) {
            List<UserAvatarMedal> userAvatorMedalInfo = MedalUtil.getUserAvatorMedalInfo(arrayValue);
            if (userAvatorMedalInfo != null) {
                String str = "";
                for (int i = 0; i < userAvatorMedalInfo.size(); i++) {
                    str = i == userAvatorMedalInfo.size() - 1 ? str + userAvatorMedalInfo.get(i).getUrl() : str + userAvatorMedalInfo.get(i).getUrl() + ";";
                }
                setMedalSmall(str);
            } else {
                setMedalSmall(null);
            }
            setUserAvatarMedals(userAvatorMedalInfo);
        }
        if (jSONObject.has("main_team")) {
            String stringValue = JsonUtil.getStringValue("main_team", jSONObject);
            if (stringValue != null && (lastIndexOf = stringValue.lastIndexOf(Separators.COLON)) > 0) {
                stringValue = stringValue.substring(0, lastIndexOf);
            }
            setMainTeam(stringValue);
        }
        setCityName(JsonUtil.getStringValue("city_name", jSONObject));
        setPlateNum(JsonUtil.getStringValue("license_number", jSONObject));
        setProName(JsonUtil.getStringValue("pro_name", jSONObject));
    }

    public String getProName() {
        return this.proName;
    }

    public void setProName(String str) {
        this.proName = str;
    }

    public String getPlateNum() {
        return this.plateNum;
    }

    public void setPlateNum(String str) {
        this.plateNum = str;
    }

    public int getLevel() {
        return this.level;
    }

    public void setLevel(int i) {
        this.level = i;
    }

    public String getMedalSmall() {
        return this.medalSmall;
    }

    public void setMedalSmall(String str) {
        this.medalSmall = str;
    }

    public List<UserAvatarMedal> getUserAvatarMedals() {
        return this.userAvatarMedals;
    }

    public void setUserAvatarMedals(List<UserAvatarMedal> list) {
        this.userAvatarMedals = list;
    }

    public String getPicUrl() {
        return this.picUrl;
    }

    public String getUserName() {
        return this.userName;
    }

    public long getUserId() {
        return this.userId;
    }

    public void setUserId(long j) {
        this.userId = j;
    }

    public void setUserName(String str) {
        this.userName = str;
    }

    public void setPicUrl(String str) {
        this.picUrl = str;
    }

    public int getAge() {
        return this.age;
    }

    public int getSex() {
        return this.sex;
    }

    public long getTotalDistance() {
        return this.totalDistance;
    }

    public void setAge(int i) {
        this.age = i;
    }

    public void setSex(int i) {
        this.sex = i;
    }

    public void setTotalDistance(long j) {
        this.totalDistance = j;
    }

    public String getMainTeam() {
        return this.mainTeam;
    }

    public void setMainTeam(String str) {
        this.mainTeam = str;
    }

    public String getCityName() {
        return this.cityName;
    }

    public void setCityName(String str) {
        this.cityName = str;
    }

    @Override
    public void writeToParcel(Parcel parcel, int i) {
        parcel.writeLong(this.userId);
        parcel.writeString(this.userName);
        parcel.writeString(this.picUrl);
        parcel.writeInt(this.age);
        parcel.writeInt(this.sex);
        parcel.writeLong(this.totalDistance);
        parcel.writeInt(this.level);
        parcel.writeTypedList(this.userAvatarMedals);
        parcel.writeString(this.medalSmall);
        parcel.writeString(this.mainTeam);
        parcel.writeString(this.cityName);
        parcel.writeString(this.plateNum);
        parcel.writeString(this.proName);
    }

    protected WorkoutLike(Parcel parcel) {
        this.userId = parcel.readLong();
        this.userName = parcel.readString();
        this.picUrl = parcel.readString();
        this.age = parcel.readInt();
        this.sex = parcel.readInt();
        this.totalDistance = parcel.readLong();
        this.level = parcel.readInt();
        this.userAvatarMedals = parcel.createTypedArrayList(UserAvatarMedal.CREATOR);
        this.medalSmall = parcel.readString();
        this.mainTeam = parcel.readString();
        this.cityName = parcel.readString();
        this.plateNum = parcel.readString();
        this.proName = parcel.readString();
    }
}
